require 'yaml'


class Module
  def has_many(sym)
    puts sym
  end
  
  def properties(*args)
    args.each do |arg|
      class_eval <<-EOC
        def #{arg}
          @props ||= {}
          @props[:#{arg}]
        end
        
        def #{arg}=(value)
        @props ||= {}
          @props[:#{arg}] = value
        end
      EOC
    end
    
    class_eval <<-EOC
      def to_yaml_properties
       ['@props']
      end
    EOC
    
  end
  

end

class MudBase
  
  def save
    #puts self.file_name
    File.open(self.file_name, 'w') do |file|
      YAML::dump(self, file)
    end
    self
  end
  
  def data_root
    "data/#{self.class}/"
  end
  
  def file_name
    "data/#{self.class}/#{self.name}.yaml"
  end
  
  def self.metaclass
    class << self
      self
    end
  end
  
end
